package cn.jsj.invite.interceptor;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;

public class SimpleMailFactory {
    @Value("${spring.mail.username}")
    private String hostMailAddress;


    /**
     * 构造一个邮件对象
     *
     * @param aimAddress 收件邮箱（用户邮箱）
     * @param text       邮件的文字内容
     * @param subject    邮件标题
     * @return 邮件实体（返回值保证不为null）
     */
    public SimpleMailMessage getSimpleMailMessage(String aimAddress, String text, String subject) {
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom(this.hostMailAddress);
        simpleMailMessage.setTo(aimAddress);
        simpleMailMessage.setText(text);
        simpleMailMessage.setSubject(subject);
        return simpleMailMessage;
    }
}
